﻿package src.libCom 
{
	import debugs.Debug;
	import infos.LRCinfo;
	import infos.triggerInfo;
	import net.netvars;
	/**
	 * ...
	 * @author keys_star@163.com
	 */
	public class FixLrc 
	{
		public var LRCITEM:Array;
		public function FixLrc(x:XML) 
		{
			fix(x);
		}
		private function fix(x:XML):void {
			//Debug.send(this + ".XML: " + x);
			var time = x.config.@startTime;
			var etime = x.config.@endTime;
			var bgColor = Number(x.config.@bgColor);
			var fColor = Number(x.config.@fColor);
			//Debug.send(this + ".startTime: " + time);
			netvars.setVar("StartTime", time);
			netvars.setVar("EndTime", etime);
			netvars.setVar("bgColor", bgColor);
			netvars.setVar("fColor", fColor);
			var wl:XMLList = x.word;
			Debug.send(this + ".len: " + wl.length());
			var arr:Array = new Array;
			for (var i = 0; i < wl.length(); i++ ) {
				var triggItem:Array = new Array;
				var lrcInfo:LRCinfo = new LRCinfo;
				arr.push(lrcInfo);
				lrcInfo.lrc = wl[i].@txt;
				lrcInfo.startTime = wl[i].@time;
				lrcInfo.tirgger = triggItem;
				//Debug.send(this + ".word: " + wl[i].@txt);
				//Debug.send(this + ".stime: " + wl[i].@time);
				var trig:XMLList = wl[i].Trigger;
				//Debug.send(this + ".trig: " + trig);
				for (var j = 0; j < trig.length(); j++ ) {
					var triginfo:triggerInfo = new triggerInfo;
					triginfo.startTime = trig[j].@time;
					triginfo.id = trig[j].@id;
					triginfo.duration = trig[j].@duration;
					triggItem.push(triginfo);
					//Debug.send(this + ".trig.time: " + trig[j].@time);
				}
			}
			LRCITEM = arr;
		}
	}
}